home *** CD-ROM | disk | FTP | other *** search
- //***********************************************************************
- //
- // MainFrame.cpp
- //
- //***********************************************************************
-
- #include <afxwin.h>
- #include <afxext.h>
- #include <afxmt.h>
- #include "Resource.h"
- #include "MainFrame.h"
- #include "MTDoc.h"
-
- IMPLEMENT_DYNCREATE (CMainFrame, CFrameWnd)
-
- BEGIN_MESSAGE_MAP (CMainFrame, CFrameWnd)
- ON_WM_CREATE ()
- ON_MESSAGE (WM_USER_UPDATE_STATS, OnUpdateImageStats)
- ON_MESSAGE (WM_USER_THREAD_UPDATE, OnThreadUpdate)
- ON_MESSAGE (WM_USER_THREAD_FINISHED, OnThreadFinished)
- ON_MESSAGE (WM_USER_THREAD_ABORTED, OnThreadAborted)
- ON_WM_QUERYNEWPALETTE ()
- ON_WM_PALETTECHANGED ()
- END_MESSAGE_MAP ()
-
- CMainFrame::CMainFrame ()
- {
- m_nPercentDone = -1;
- }
-
- int CMainFrame::OnCreate (LPCREATESTRUCT lpcs)
- {
- static UINT nIndicators[] = {
- ID_SEPARATOR,
- ID_SEPARATOR,
- };
-
- if (CFrameWnd::OnCreate (lpcs) == -1)
- return -1;
-
- if (!m_wndStatusBar.Create (this))
- return -1;
-
- m_wndStatusBar.SetIndicators (nIndicators, 3);
-
- TEXTMETRIC tm;
- CClientDC dc (this);
- CFont* pFont = m_wndStatusBar.GetFont ();
- CFont* pOldFont = dc.SelectObject (pFont);
- dc.GetTextMetrics (&tm);
- dc.SelectObject (pOldFont);
-
- int cxWidth;
- UINT nID, nStyle;
- m_wndStatusBar.GetPaneInfo (1, nID, nStyle, cxWidth);
- m_wndStatusBar.SetPaneInfo (1, nID, nStyle, tm.tmAveCharWidth * 24);
- m_wndStatusBar.SetPaneInfo (2, nID, nStyle, tm.tmAveCharWidth * 8);
- return 0;
- }
-
- LONG CMainFrame::OnUpdateImageStats (UINT wParam, LONG lParam)
- {
- m_wndStatusBar.SetPaneText (1, (LPCTSTR) lParam, TRUE);
- return 0;
- }
-
- LONG CMainFrame::OnThreadUpdate (UINT wParam, LONG lParam)
- {
- int nPercentDone = ((int) wParam * 100) / (int) lParam;
- if (nPercentDone != m_nPercentDone) {
- m_nPercentDone = nPercentDone;
- CString string;
- string.Format ("%d%%", m_nPercentDone);
- m_wndStatusBar.SetPaneText (2, (LPCTSTR) string, TRUE);
- }
- return 0;
- }
-
- LONG CMainFrame::OnThreadFinished (UINT wParam, LONG lParam)
- {
- ((CMTDoc*) GetActiveDocument ())->ThreadFinished ();
- m_wndStatusBar.SetPaneText (2, "", TRUE);
- m_nPercentDone = -1;
- return 0;
- }
-
- LONG CMainFrame::OnThreadAborted (UINT wParam, LONG lParam)
- {
- ((CMTDoc*) GetActiveDocument ())->ThreadAborted ();
- m_wndStatusBar.SetPaneText (2, "", TRUE);
- m_nPercentDone = -1;
- return 0;
- }
-
- BOOL CMainFrame::OnQueryNewPalette ()
- {
- GetActiveView ()->Invalidate (FALSE);
- return TRUE;
- }
-
- void CMainFrame::OnPaletteChanged (CWnd* pFocusWnd)
- {
- if (pFocusWnd != this)
- GetActiveView ()->Invalidate (FALSE);
- }
-